<%@ page import="java.util.Date" %>
<%@ page import="java.util.Calendar" %><%--
  Created by IntelliJ IDEA.
  User: q
  Date: 2022/6/8
  Time: 上午 9:27
  To change this template use File | Settings | File Templates.
--%>



<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head background = "./image/abc.png">
    <title>时间</title>
</head>
<body>
<script>
    var sum = 0;
    for (let i = 0; i < 100 ; i++) {
        sum +=i;
    }
    document.write("<h1>1+2+...+99="+ sum +"</h1>");
    var clientDate = new Date();
    let hours = clientDate.getHours();
    let minutes = clientDate.getMinutes();
    let seconds = clientDate.getSeconds();
    let milliseconds = clientDate.getMilliseconds();
    document.write("<h1>客户端时间是："+ hours+":" +minutes+":" +seconds+"." +milliseconds +"</h1>");
</script>
    <%
    Date serverDate = new Date();
    Calendar cal= Calendar.getInstance();
    cal.setTime(serverDate);
    int hours = cal.get(Calendar.HOUR_OF_DAY);
    int minutes = cal.get(Calendar.MINUTE);
    int seconds = cal.get(Calendar.SECOND);
    int milliseconds = cal.get(Calendar.MILLISECOND);
    %>
<h1>
    <%=
    "服务器时间是："+hours+":" +minutes+":" +seconds+"." +milliseconds
    %>
</h1>
</body>
</html>
